/*-------------------------------------------------------------------------

   File :         iso8.h
   Project :      VeriFone Base application
   Library :
   Description :
   Notes :
   Modification History :
     #     Date      Who                     Description
   ----- -------- ---------- ---------------------------------------------
 **************************************************************************

   Copyright (C) 1995 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/

#ifdef ISO8583_DEFINED

#include <iso8583.h>

typedef struct iso_struct
{
	int inStatus;

	/* used to pack and unpack 8583 packets	*/
	field_struct *pFldTable;

	/* Completed transmit packet bit map.
	 * All needed fields bits should be on
	 */
	unsigned char stOptionalMapISO8583[ISO8583_BIT_MAP_SIZE];
	unsigned char stMapISO8583[ISO8583_BIT_MAP_SIZE];

	/* Used to save the Message type and TPDU before sending packet */
	unsigned char szSavedTPDU[ISO8583_TPDU_SIZE + 1];	/* TPDU  */
	unsigned char btSavedMti[ISO8583_MTI_SIZE];			/* Saved Message Type Id  */

	/* Reversal message ID, if a reversal is processed, the
	 * string in this buffer is used as the message ID for the
	 * reversal message
	 */
	unsigned char btRevMsgId[ISO8583_MTI_SIZE];

	/* Name of the reversal file */
	unsigned char stRevFileName[FILENAME_SIZE + 1];

	/* ISO Packet Validation properties */
	void *psrValidationParms;
	unsigned int inValidationParmsSize;

	/**** TRANSMIT BUFFER PROPERTIES ********/
	unsigned char *pchTransmitBuff;		/* Transmit Buffer */
	unsigned int inTransmitSize;		/* Dynamic Size of transmit data (Set in SendISO8583) */
	unsigned int inTransmitBuffSize;	/* Maximum size of the Transmit buffer */

	/**** RECEIVE BUFFER PROPERTIES ********/
	unsigned char *pchReceiveBuff;		/* Receive Buffer */
	unsigned int inReceiveBuffSize;		/* Dynamic size of received data (Set in ReceiveISO8583) */
	unsigned int inReceiveSize;			/* Maximum size of the Receive buffer */

	/**** REVERSAL BUFFER PROPERTIES ********/
	unsigned char *pchReversalBuff;		/* Reversal Buffer */
	unsigned int inReversalBuffSize;	/* Dynamic size of reversal data */
	unsigned int inReversalSize;		/* Maximum size of the Reversal buffer  */

	/* ISO Table record */
	IST_REC srISTRec;
} ISO_OBJECT;

int inInitializeISO8583 (PACKET_OBJECT *);
int inDefaultISO8583ModifyBatchRec(TRANSACTION_OBJECT *);
int inISO8583ModifyBatchRec(TRANSACTION_OBJECT *);
int inInitializeISO8583Frame(void);
void vdOverLoadProcessOfflineTran ( int (*inNewProcessOfflineTran)());
void vdOverLoadUpdateISO8583ResponseCounters (int (*inNewUpdateISO8583ResponseCountersFunc)());
int inDefaultUpdateISO8583ResponseCounters(TRANSACTION_OBJECT *);

void vdOverLoadISO8583PreUnpackFunc (int (*inNewISO8583PreUnpackFunc)());
void vdOverLoadISO8583UnpackFunc (int (*inNewISOUnpack)());
void vdOverLoadCustomAnalyseFunction (int (*inNewCustomAnalyseFunctionFunc)());
void vdOverLoadAddlInitializeISO8583( int (*inNewAddlInitializeISO8583)(PACKET_OBJECT *));
void vdOverLoadISO8583PrePack(void (*vdNewISO8583PrePack)());
int inAddISO8583Functions(void);
int inAddISO8583ProtFunctions(void);
int inISO8583Init (PACKET_OBJECT *);
int inISO8583Deinitialize (PACKET_OBJECT *);
void vdDefaultISO8583PrePack(PACKET_OBJECT *);
int inISO8583Pack (PACKET_OBJECT *);
int inDefaultISO8583Unpack (PACKET_OBJECT *);
int inISO8583Unpack(PACKET_OBJECT *);
int inDefaultProcessOfflineTran (PACKET_OBJECT *);
int inValidateISO8583Response (PACKET_OBJECT *);
int inDefaultCustomAnalyseFunction(PACKET_OBJECT *);
int inISO8583Analyse (PACKET_OBJECT *);
int inISO8583Batch (PACKET_OBJECT *);
int inISO8583Debatch (PACKET_OBJECT *);
int inDefaultAddlInitializeISO8583 (PACKET_OBJECT *);
int inSetISO8583Fields (PACKET_OBJECT *);

extern const char  *szGlobalISO8583Response;
extern void (*vdISO8583SetRevMsgId)(ISO_OBJECT *);

/* -------------- */
void vdOverLoadISO8583SetRevMsgId(void (*)(ISO_OBJECT *));

#endif /* ISO8583_DEFINED */
